package com.engineering.elink.service.impl;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Service;

import com.engineering.elink.service.CookieService;

import common.util.CookieUtil;

@Service
public class CookieServiceImpl implements CookieService{

	@Override
	public void setCookie(HttpServletResponse response, String key, String value, int maxAge) {
		CookieUtil.addCookie(response, key, value, maxAge);
	}

	@Override
	public String getCookie(HttpServletRequest request, String key) {
		Cookie cookie = CookieUtil.getCookieByName(request, key);
		String value = "";
		if (cookie != null) {
			value = cookie.getValue();
			if (value != null && !value.equals("")) {
				return value;
			}
		}
		return null;
	}

	@Override
	public void removeCookie(HttpServletRequest request) {
		// TODO Auto-generated method stub
		
	}
}
